function area = triangle_area(V)
dim = size(V,2);
if dim == 2
    temp = [1/2 V(1,:); 1/2 V(2,:); 1/2 V(3,:)];
    area = abs(det(temp));
elseif dim == 3
    v1 = V(1,:);
    v2 = V(2,:);
    v3 = V(3,:);
    cross_product = cross(v2-v1, v3-v1);
    area = 0.5*norm(cross_product);
end
end